<?php

namespace addons\yunfood\model;

use addons\yunfood\library\ModelTrait;

/**
 * 会员用户模型
 */
class User extends \app\common\model\User
{
    use ModelTrait;

    protected $resultSetType = 'collection';

    // 性别
    const GENDER_MALE   = 1;
    const GENDER_FAMALE = 0;
    const GENDER_NONE   = 2;

    public static function getGenderList()
    {
        return [
            self::GENDER_MALE   => __('男'),
            self::GENDER_FAMALE => __('女'),
            self::GENDER_NONE   => __('无')
        ];
    }

    public function getGenderTextAttr($value, $data)
    {
        $optionList = self::getGenderList();

        return $optionList[$data['gender']] ?? $data['gender'];
    }

    // 状态
    const STATUS_NORMAL = 'normal';
    const STATUS_HIDDEN = 'hidden';

    public static function getStatusList()
    {
        return [self::STATUS_NORMAL => __('Normal'), self::STATUS_HIDDEN => __('屏蔽')];
    }

    public function getStatusTextAttr($value, $data)
    {
        $optionList = self::getStatusList();

        return $optionList[$data['status']] ?? $data['status'];
    }
}
